package com.iacrqq.sedaf.event;

import com.iacrqq.sedaf.common.Destroyable;
import com.iacrqq.sedaf.common.Initializable;
import com.iacrqq.sedaf.event.exception.EventHandlerException;

/**
 * An EventHandler represents an event handler - the basic unit of
 * computation. This is the basic interface which all
 * application modules implement. 
 * 
 * @author sihai
 *
 */
public interface EventHandler extends Initializable, Destroyable{

	/**
	 * Handle the event corresponding to the given event. This method
	 * is invoked by the system when a single event is pending for the event
	 * handler.
	 * 
	 * @param event
	 * @param eventDispatcher
	 * 
	 * @exception EventHandlerException
	 *                The application may throw an exception to indicate an
	 *                error condition during event processing.
	 */
	public Event handleEvent(Event event, EventDispatcher eventDispatcher) throws EventHandlerException;

	/**
	 * Handle the events corresponding to the given Event array. This
	 * method is invoked when multiple events are pending for the event handler.
	 * The application may reorder, filter, or drop these events if it wishes to
	 * do so.
	 * 
	 * @exception EventHandlerException
	 *                The application may throw an exception to indicate an
	 *                error condition during event processing.
	 */
	public Event[] handleEvents(Event[] events, EventDispatcher eventDispatcher) throws EventHandlerException;
}
